package src.view;

import src.event.EventListener;
import src.event.events.MapUpdateEvent;

/**
 * <b>Overview</b>
 * The MapCacheHandler translates all aspects of the current map to be displayed.  It instructs the MapDataCache how to update itself based on incoming events.
 *
 * <b>Responsibilities</b>
 * Translates all changes to the model so that the view can be drawn quickly from the representation.
 *
 * <b>Collaborators</b>
 * MapDataCache - Client: The MapDataCache is instructed
 * MapUpdateEvent - Subcontractor: MapUpdateEvents contain the information about changes to the map that have occurred and need to be displayed.
 *
 * <b>Implementor</b> - Bruce
 * <b>Tester</b> - Tim
 *
 * @author Bruce
 */
public class MapCacheHandler implements EventListener<MapUpdateEvent>
{
	private MapDataCache cache;

	public MapCacheHandler(MapDataCache cache)
	{
		this.cache = cache;
	}

	/* (non-Javadoc)
	 * @see src.event.EventListener#eventCallback(src.event.Event)
	 */
	public boolean eventCallback(MapUpdateEvent e)
	{
		cache.forward(e);
		cache.setMap(e.getMap());
		return true;
	}
}